import { reqRegisterInfo, reqIsRegister } from "@/api"
// 小仓库
const state = {
  showNum: 1,
  phone: '',
  password: '',
  isreg: 0
}
const mutations = {
  CHANGESHOWNUM(state, { num, phone, password }) {
    state.showNum = num
    state.phone = phone
    state.password = password
  },
  ISREGISTER(state, isreg) {
    state.isreg = isreg
  }
}
const actions = {
  changeShowNum({ commit }, { num, phone, password }) {
    commit('CHANGESHOWNUM', { num, phone, password })
  },
  async registerInfo({ commit }, { user_name, user_phone, user_password, user_avatar }) {
    let data = { user_name, user_phone, user_password, user_avatar }
    let result = await reqRegisterInfo(data)
    // console.log(result);
  },
  async isregister({ commit }, user_phone) {
    let result = await reqIsRegister(user_phone)
    // console.log(111, result);
    if (result.data.length > 0) {
      commit('ISREGISTER', 1)
    } else {
      commit('ISREGISTER', 0)
    }
  },
  changeShowNums({ commit }, num) {
    commit('ISREGISTER', num)
  }
}
const getters = {}
export default {
  state,
  mutations,
  actions,
  getters
}